<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>影片评论资料列表</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/forum/list?movieId=${movieId}&cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/forum/list?movieId=${movieId}&cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 45
        });
    });

    function edit() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要修改的影片评论");
            return;
        }
        if (ids.length > 1) {
            alert("只能选择一笔影片评论");
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        url = "${pageContext.request.contextPath }/forum/update?movieId=" + arr;
        location.href = url;
    }

    function getRowData(value, rec) {
        var id = rec.id;
        $("#forumId").val(id);
        $("#mobile").val(rec.mobile);
        $("#grade").val(rec.grade);
        $("#remark").val(rec.remark);
        $("#forumDate").datebox("setValue", rec.forumDate);
    }

    function save() {
        document.forms[1].submit();
    }

    function add() {
        $("#forumId").val(0);
        $("#mobile").val("");
        $("#grade").val("");
        $("#remark").val("");
        var d = new Date();
        $("#forumDate").datebox("setValue", d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
    }

    function del() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要删除的影片评论");
            return;
        }
        if (!confirm('删除演职人确认')) {
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        var url = "${pageContext.request.contextPath }/forum/del?ids=" + arr;
        location.href = url;
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
       BACKGROUND="${pageContext.request.contextPath }/images/maintitle.jpg" class="tablelist2">
    <form action="${pageContext.request.contextPath }/forum/save" method="post">
        <input type="hidden" name="forumId" id="forumId" value="${forum.forumId}">
        <tr class="tableselect2">
            <td align="left">
                <div class="tools">
                    <ul class="toolbar">
                        <li><a href="javascript:void(0);" onclick="add();"><span><img
                                src="${pageContext.request.contextPath }/images/add.png"></span>添加</a></li>
                        <li><a href="javascript:void(0);" onclick="del();"><span><img
                                src="${pageContext.request.contextPath }/images/delete.png"></span>删除</a></li>
                    </ul>
                </div>
            </td>
            <td align="right">
                <input type="hidden" name="forumId" id="forumId" value="0">
                手机号码:<input type="text" name="mobile" id="mobile" style="width:100px">
                评分:<select name="grade" id="grade" style="width:80px">
                <c:forEach begin="1" end="10" var="v">
                    <option value="${v}">${v}分</option>
                </c:forEach>
            </select>
                日期:<input type="text" class="easyui-datebox" name="forumDate" id="forumDate" style="width: 100px;">
                评论：<input type="text" name="remark" id="remark" style="width:500px">
                <input type="submit" value="保存">
            </td>
        </tr>
    </form>
</table>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px" singleSelect="false"
       data-options="onClickRow:getRowData">
    <thead>
    <tr>
        <th field="id" checkbox="true" width=50>选择</th>
        <th field="mobile" width=200 align="center">手机号码</th>
        <th field="grade" width=100 align="center">影片评分</th>
        <th field="forumDate" width=200 align="center">评论日期</th>
        <th field="remark" width=500 align="center">影片评论</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" var="v">
        <tr>
            <td>${v.forumId }</td>
            <td>${v.mobile }</td>
            <td>${v.grade }</td>
            <td>${v.forumDate }</td>
            <td>${v.remark }</td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>